package com.design.yjx.proxy.remote;

import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;

/**
 * @author yuanjianxin
 * @date 2017/8/25 14:29
 */
public class ServiceMain {

    public static void main(String[] args) {
        try {
            GumballMachineRemote remote1 = new GumballMachine(100,"上海");
            GumballMachineRemote remote2 = new GumballMachine(200,"北京");
            GumballMachineRemote remote3 = new GumballMachine(300,"广州");

            LocateRegistry.createRegistry(9991);
            LocateRegistry.createRegistry(9992);
            LocateRegistry.createRegistry(9993);

            Naming.rebind("//192.168.1.45:9991/remote1", remote1);
            Naming.rebind("//192.168.1.45:9992/remote2", remote2);
            Naming.rebind("//192.168.1.45:9993/remote3", remote3);

            System.out.println("远程对象绑定成功");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
